<!-- include tpl=head title=邮箱修改 -->
<script type="text/javascript">
$(document).ready(function(){
	$("#userinfo_email").submit(function(){
		$(this).ajaxSubmit({
			'type':'post',
			'dataType':'json',
			'url':api_url('usercp','email'),
			'success':function(rs){
				if(rs.status){
					$.dialog.tips("您的邮箱更新成功",function(){
						$.phpok.go(get_url('usercp'));
					}).lock();
					return true;
				}
				$.dialog.alert(rs.info);
				return false;
			}
		});
		return false;
	});
});
</script>
<!-- if $sendemail -->
<script type="text/javascript">
var maxtime = 60;
var email_send_lock = false;
var win_time_out;
function update_send_email_loading()
{
	maxtime--;
	if(maxtime < 1){
		$("#email_send_status").val('发送验证码');
		email_send_lock = false;
		maxtime = 60;
		window.clearInterval(win_time_out);
		return true;
	}
	var tips = "验证码已发送("+maxtime+")";
	$("#email_send_status").val(tips);
}

function send_email()
{
	if(email_send_lock){
		$.dialog.alert('验证码已发送，请一分钟后再执行');
		return false;
	}
	var url = api_url('vcode','email');
	var email = $("#email").val();
	if(!email){
		$.dialog.alert('邮箱不能为空');
		return false;
	}
	url += "&email="+email;
	$.dialog.tips("正在执行中，请稍候…").lock();
	update_send_email_loading();
	$.phpok.json(url,function(rs){
		if(rs.status){
			maxtime = 60;
			email_send_lock = true;
			win_time_out = setInterval("update_send_email_loading()",1000);
			return true;
		}
		$.dialog.alert(rs.info);
		$("#email_send_status").val('发送验证码');
	})
}
</script>
<!-- /if -->
<div class="main">
	<div class="am-panel am-panel-default">
		<div class="am-panel-hd">邮箱修改</div>
		<div class="am-panel-bd">
			<form class="am-form am-form-horizontal" method="post" id="userinfo_email">
			<div class="am-form-group">
				<label for="pass" class="am-u-sm-12 am-form-label">会员密码</label>
				<div class="am-u-sm-12"><input type="password" name="pass" id="pass" /></div>
			</div>
			<!-- if $rs.email -->
			<div class="am-form-group">
				<label for="oldemail" class="am-u-sm-12 am-form-label">原邮箱</label>
				<div class="am-u-sm-12"><input type="text" name="oldemail" id="oldemail" value="{$rs.email}" disabled /></div>
			</div>
			<!-- /if -->
			<div class="am-form-group">
				<label for="email" class="am-u-sm-12 am-form-label">新邮箱</label>
				<div class="am-u-sm-12"><input type="text" name="email" id="email" /></div>
				<!-- if $sendemail -->
				<div class="am-u-sm-12" style="margin-top:1em;"><input type="button" value="发送验证码" onclick="send_email()" class="am-btn am-btn-default am-btn-block" id="email_send_status" /></div>
				<!-- /if -->
			</div>
			<!-- if $sendemail -->
			<div class="am-form-group">
				<label for="chkcode" class="am-u-sm-12 am-form-label">验证码</label>
				<div class="am-u-sm-12"><input type="text" name="chkcode" id="chkcode" /></div>
			</div>
			<!-- /if -->
			<div class="am-form-group">
				<div class="am-u-sm-12"><input type="submit" id="phpok_submit" value="提 交" class="am-btn am-btn-block am-btn-primary"></div>
			</div>
			</form>
		</div>
	</div>
	<div class="am-panel am-panel-default">
		<div class="am-panel-hd">友情说明</div>
		<div class="am-panel-bd">
			<ul class="tip">
				<li>邮箱修改需要您提供会员密码认证</li>
				<li>请确填写有效的邮箱，国内用户建议使用126邮箱或QQ邮箱</li>
			</ul>
		</div>
	</div>
</div>

<!-- include tpl=foot -->